package com.higgins.eventtracking.server.projectmanagement;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.jdo.annotations.Element;
import javax.jdo.annotations.Embedded;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import com.higgins.eventtracking.client.projectmanagement.ProjectItemDTO;
import com.higgins.eventtracking.server.DateUtility;

@PersistenceCapable
public class ProjectItem {
	@SuppressWarnings("unused")
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
	@Persistent
	private Long parentId;
	@Persistent
	private Integer priority;
	@Persistent
	private String task;
	@Persistent
	private Double forecast;
	@Persistent
	private Double actual;
	@Persistent
	private Double complete;
	@Persistent
	private Boolean permanent;
	@Persistent
	private Boolean immediate;
	@Persistent
	private Boolean followUp;
	@Persistent
	private Date startTimestamp;
	@Persistent
	private Date endTimestamp;
	@Persistent
	private Date followUpDate;

	public ProjectItem()	{
		startTimestamp = new Date();
	}
	public void setId(Long id)	{
		//this.id = id;
	}
	public Long getId()	{
		return id;
	}
	public void setParentId(Long parentId)	{
		this.parentId = parentId;
	}
	public Long getParentId()	{
		return parentId;
	}
	public void setPriority(Integer priority)	{
		this.priority = priority;
	}
	public Integer getPriority()	{
		return priority;
	}
	public void setTask(String task)	{
		this.task = task;
	}
	public String getTask()	{
		return task;
	}
	public void setForecast(Double forecast)	{
		this.forecast = forecast;
	}
	public Double getForecast()	{
		return forecast;
	}
	public void setActual(Double actual)	{
		this.actual = actual;
	}
	public Double getActual()	{
		return actual;
	}
	public Double getComplete()	{
		return complete;
	}
	public void setComplete(Double complete)	{
		this.complete = complete;
	}
	public Boolean getPermanent()	{
		return permanent;
	}
	public void setPermanent(Boolean permanent)	{
		this.permanent = permanent;
	}
	public Boolean getImmediate()	{
		return immediate;
	}
	public void setImmediate(Boolean immediate)	{
		this.immediate = immediate;
	}
	public Boolean getFollowUp()	{
		return followUp;
	}
	public void setFollowUp(Boolean followUp)	{
		this.followUp = followUp;
	}
	public Date getFollowUpDate()	{
		return followUpDate;
	}
	public void setFollowUpDate(Date followUpDate)	{
		this.followUpDate = followUpDate;
	}
	public Date getStartTimestamp()	{
		return startTimestamp;
	}
	public void setStartTimestamp(Date startTimestamp)	{
		this.startTimestamp = startTimestamp;
	}
	public Date getEndTimestamp()	{
		return endTimestamp;
	}
	public void setEndTimestamp(Date endTimestamp)	{
		this.endTimestamp = endTimestamp;
	}
//	public void addChild(Long id)	{
//		children.add(id);
//	}
//	public List<Long> getChildren()	{
//		return children;
//	}
//	public void setChildren(List<Long> children)	{
//		this.children = children;
//	}
	public void update(ProjectItemDTO dto)	{
		setId(dto.getId());
		setParentId(dto.getParentId());
		setPriority(dto.getPriority());
		setTask(dto.getTask());
		setForecast(dto.getForecast());
		setActual(dto.getActual());
		setComplete(dto.getComplete());
		setPermanent(dto.getPermanent());
		setImmediate(dto.getImmediate());
		setFollowUp(dto.getFollowUp());
		setFollowUpDate(DateUtility.convertStringToDate(dto.getFollowUpDateString()));
		setStartTimestamp(dto.getStartTimestamp());
		setEndTimestamp(dto.getEndTimestamp());
//		setChildren(dto.getChildren());

	}
	public ProjectItemDTO getDTO()	{
		ProjectItemDTO dto = new ProjectItemDTO();
		dto.setId(id);
		dto.setParentId(parentId);
		dto.setPriority(priority);
		dto.setTask(task);
		dto.setForecast(forecast);
		dto.setActual(actual);
		dto.setComplete(complete);
		dto.setPermanent(permanent);
		dto.setImmediate(immediate);
		dto.setFollowUp(followUp);
		dto.setFollowUpDate(followUpDate);
		dto.setFollowUpDateString(DateUtility.convertDateToString(followUpDate));
		dto.setStartTimestamp(startTimestamp);
		dto.setEndTimestamp(endTimestamp);
//		dto.setChildren(children);
		return dto;
	}
}
